import React from 'react';
import shallowEqual from 'react-pure-render/shallowEqual';
import { withRouter } from 'react-router'

class RComponent extends React.Component {
    shouldComponentUpdate(nextProps, nextState) {
        return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState);
    }
    componentDidMount() {
        this.props.router.setRouteLeaveHook(this.props.route, () => {
            if (this.state.unsaved)
                return '还有数据未保存，确定离开？'
        })
    }
}
export default withRouter(RComponent)
